﻿Public Class frmKetNoi
    Private Sub chkSecure_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkSecure.CheckedChanged
        If chkSecure.Checked = False Then
            Me.txtUser.ReadOnly = False
            Me.txtPass.ReadOnly = False
        Else
            Me.txtUser.ReadOnly = True
            Me.txtPass.ReadOnly = True
        End If
    End Sub

    Private Sub btnDangNhap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDangNhap.Click
        Me.btnDangNhap.Enabled = False
        Dim clsKetnoi As New clsKetNoi()
        Dim strError As String = ""
        If chkSecure.Checked = False Then ' Trường hợp bỏ check ở checkbox
            strError = clsKetnoi.fncKetNoiCoChiDinhUser(Me.txtMayChu.Text, Me.txtCSDL.Text, txtUser.Text, txtPass.Text)
        Else ' Trường hợp có check vào checkbox
            strError = clsKetnoi.fncKetNoiVoiQuyenCuaWindow(Me.txtMayChu.Text, Me.txtCSDL.Text)
        End If
        If strError = "" Then ' Không phát sinh lỗi
            Me.Close()
        Else
            MsgBox(strError, MsgBoxStyle.Information, "Thông báo")
        End If
        Me.btnDangNhap.Enabled = True
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class
